# ********************************************
# * Player / Stage Connection Script         *
# * Parallel Version                         *
# * Authors: André Bannwart Perina           *
# *          Antonio Canabrava Fraideinberze *
# *          Willian Felipe Lopes da Silva   *
# ******************************************** 

if [ $# -ne 2 ]; then
	echo "Usage: $0 numProc numIters"
	exit
fi

# For the number of individuals/iterations run the program
c=0
while (( $c < $1))
do
    # Runs the serial version of the algorithm using the arguments passed as parameters
    sh ./robot.sh $((6600+$c)) $(($2/$1)) $(($c*($2/$1))) &
    c=$((c+1))
done

# Waits for the last instance to finish
while [ $(ps aux | grep " sh ./robot.sh " | wc -l) -gt 1 ]
do
	sleep 1
done